<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws.
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.).
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations).
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Listing/classes/PhpFox_ComponentListingList.class.php, $Author:  $ */



/** Display list classifieds
 *
 * Parameters:
 *  1. oUser (mandatory) - user account object
 *
 * @package module.listing
 * @version $Id:
 *   PHPFox Team ()
 */
class PhpFox_Mod_Listing_ComponentListingList extends BaseComponent
{
	function process()
	{
	    //check permissions
        $oSecurityService = App::getModuleService('Account', 'Security');
		/* @var $oSecurityService PhpFox_Mod_Account_ServiceSecurity */
		$oListingService = $this->_oModule->getService('Listing');
        /* @var $oGroupsService PhpFox_Mod_Groups_ServiceGroups */
        $oSecurityService->checkPerm('listing', array('read_only', 'full'));
        App::loadClass('Filter');

        $oReq = &App::getRequest();
        /* @var $oReq Request */

        $oTpl = $this->_oModule->getTemplate();

        $aCatHash = array();
        $aCatHash[''] = App::format('view_all');
        foreach($oListingService->getCategoryHash() as $i=>$sCat)
            $aCatHash[$i] = $sCat;

        $aCountry[''] = App::format('core.any');
        foreach(App::getTxtFile('country.txt') as $i=>$sCountry)
	        $aCountry[$sCountry] = $sCountry;
        $aState[''] = App::format('core.any');
        foreach(App::getTxtFile('us_stat.txt') as $i=>$sState)
	        $aState[$sState] = $sState;

        $aFilter = array
        (
            'location' => array
            (
                'value'  => '=',
                'select' => $aCountry,
            ),
            'state' => array
            (
                'value'  => '=',
                'select' => $aState,
            ),
            'list_id' => array
            (
                'value'  => '=',
                'select' => $aCatHash,
            ),
            'city'   => 'like',
            'title'  => 'like',
        );
        $oFilter = &new Filter('listing', $aFilter);
        $oFilter->reset();
        $oFilter->activateFilter();

        $aCatListing = $oListingService->listCategories();

        $oTpl->assignSrc(array(
                               'aFilter'      => $oFilter->aHtml,
                               'aCatHash' => $aCatHash,
                               'aCatList' => $aCatListing,
                               'bZipState'   => App::getSetting('us_states'),
                                ));

        $srcHtml = $oTpl->fetch('ListingList.html');
		return $srcHtml;
	}
}
?>